<?php
session_start();
    
    // Created By : Julian Ponce
    // B.S. Computer Science - De La Salle Canlubang
    // October 27, 2011
    // IN PARAMETERS : documentId
    // 
    // This AJAX updates the action of a Main Document to 'Received'

// Start - Checker for those users who will just go to the page by typing directly in the url.
if ($_POST) {   
    include('../includes/siteConfig.php');
    
    // CONNECT TO DATABASE
    $connect = mysql_connect($hostName,$rootName,$dBasePassword) or die ('Unable to connect!');
    mysql_select_db($dBaseName) or die ('Unable to select database!');

    // GET VARIABLES VIA POST METHOD
    $documentId = $_POST['documentId'];
    
    $query = 
        "
            UPDATE MainDocument
            SET action = 'Received'
            WHERE mainDocumentId = '$documentId'
        ";
    mysql_query($query);
    
    
    echo json_encode(1);
    mysql_close($connect);
}   // End - Checker for those users who will just go to the page by typing directly in the url.
else {
 echo "You are not authorized to view this page. This incident will be reported immediately.";
}
?>
